<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="num1">
    <select id="fh">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
        <option value="%">%</option>
    </select>
    <input type="text" id="num2">
    <input type="button" value="=" id="btn">
    <input type="text" readonly id="result">

    <script>
        // 9. 根据已有布局，完成简易计算器功能
        var num1 = document.getElementById("num1");
        var fh = document.getElementById("fh");
        var num2 = document.getElementById("num2");
        var btn = document.getElementById("btn");
        var res = document.getElementById("result");

        btn.onclick = function(){
            if(fh.value === "+"){
                res.value = Number(num1.value) + Number(num2.value);
            }else if(fh.value === "-"){
                res.value = Number(num1.value) - Number(num2.value);
            }else if(fh.value === "*"){
                res.value = Number(num1.value) * Number(num2.value);
            }else if(fh.value === "/"){
                res.value = Number(num1.value) / Number(num2.value);
            }else if(fh.value === "%"){
                res.value = Number(num1.value) % Number(num2.value);
            }
        }
    </script>
</body>
</html>